package com.fancy.learncenter.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.activity.H5Activity;
import com.fancy.learncenter.activity.NewsH5Activity;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.HomeDataBean;
import com.fancy.learncenter.utils.LogUtil;
import com.superservice.lya.R;

import java.util.ArrayList;

/**
 * Created by hyy on 2018/1/27.
 * Explain activity as
 */

public class HomeAdapter extends CommonRecycleViewAdapter<HomeDataBean.ToplineArrBean> {


    public HomeAdapter(Context mContext, ArrayList<HomeDataBean.ToplineArrBean> itemDatas) {
        super(mContext, R.layout.fragment_home_item, itemDatas);
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final HomeDataBean.ToplineArrBean item, int position) {
        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);
        simpleDraweeView.setImageURI(item.getImgsrc());

        TextView title = customViewHold.getView(R.id.title);
        title.setText(item.getTitle());

        TextView view_num = customViewHold.getView(R.id.view_num);
        view_num.setText(item.getView_num() + "人观看");

        TextView time = customViewHold.getView(R.id.time);
        time.setText(item.getAdd_time());


        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, NewsH5Activity.class);
                intent.putExtra(H5Activity.URL_KEY,item.getUrl());
                intent.putExtra("topLineId",item.getId());

                mContext.startActivity(intent);

            }
        });

    }
}
